<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <link rel="stylesheet" href="../book.css" charset="ISO-8859-1" type="text/css"/>
        <title>Tane - Hide Delegate - Example</title>
    </head>
    <body>
    	<h1>Hide Delegate - Example</h1>
    	<p>Suppose you have code that looks like this:</p>
    	<div class="code"><pre>
Foo foo = new Foo();
&#8230;
foo.getBar().getBaz().doSomething();
    	</pre></div>
		<p>In order to move to the OO ideal of eliminating state based metaphors and focusing on message passing, we need to turn this code
			into something more like this:</p>
		<div class="code"><pre>
Foo foo = new Foo();
&#8230
foo.doSomething();
    	</pre></div>
    	<p>One way of achieving this is to implement <span class="code">Foo.doSomething()</span> like this:</p>
    	<div class="code"><pre>
public class Foo {
    &#8230;
    public void doSomething() {
        getBar().getBaz().doSomething();
    }
    &#8230;
}
    	</pre></div>
    	<p>Clearly the same process can be followed to push the behaviour further into the model so that
    		<span class="code">Foo.doSomething()</span> is implemented as <span class="code">getBar().doSomething()</span>.</p>
    		
    	<hr/>
    	<div class="attribution">
    		This plugin is provided by <a href="http://www.stateofflow.com" title="State Of Flow homepage">State Of Flow</a>
    	</div>
    </body>
</html>